home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d3 / e40ds3.arc / API.PAS < prev    next >
Pascal/Delphi Source File  |  1989-03-10  |  17KB  |  346 lines

  1. {//////////////////////////////////////////////////////////////////////////////}
  2. { This an example UNIT showing how to use the E! API interrupt routines.       }
  3. { This file may be compiled using Turbo Pascal 4.0/5.0                         }
  4. { C programmers will easily convert it to both API.H and API.C files           }
  5. {//////////////////////////////////////////////////////////////////////////////}
  6. {$A-,B-,D+,E+,F-,I-,L+,N-,R-,S-,V-}
  7.  
  8. UNIT API;
  9.  
  10. INTERFACE
  11.  
  12. USES DOS;
  13.  
  14. TYPE
  15.  
  16.  { These are the declarations of useful Records allowing you to retrieve }
  17.  { more easily E! variables values.                                      }
  18.  
  19.  FlagRecord = RECORD
  20.                AddOnLast      : boolean; { Key down insert newline on last line flag }
  21.                AlarmFlag      : boolean; { Error beep flag                      }
  22.                AsciiMode      : boolean; { Control characters entry flag        }
  23.                AutoBackFlag   : boolean; { Backspace behaviour flag             }
  24.                AutoSaveFlag   : boolean; { Autosave flag                        }
  25.                AutoScrollFlag : boolean; { Autoscroll flag                      }
  26.                AutoTabFlag    : boolean; { Autotab flag                         }
  27.                BakFlag        : boolean; { .BAK files generation flag           }
  28.                BlanksFlag     : boolean; { Strip trailing spaces when saving flag}
  29.                CompFlag       : boolean; { Compression mode flag                }
  30.                Ega_Vga_OK     : boolean; { 43 lines mode flag                   }
  31.                Flag35         : boolean; { 35 lines mode flag - EGA_VGA_OK must be on}
  32.                LogFlag        : boolean; { Log file flag                        }
  33.                PauseMode      : boolean; { Pause on return from DOS flag        }
  34.                ShiftFlag      : boolean; { Accelerated cursor flag              }
  35.                Warning        : boolean; { Warning before saving flag           }
  36.                Enter_Classic  : boolean; { Split line using ENTER flag          }
  37.                Refresh        : boolean; { Autorisation d'affichage             }
  38.               END;
  39.  
  40.  AttrRecord = RECORD
  41.                Text_Attr        : byte;  { Edited text attribute   }
  42.                BlockAttr        : byte;  { Marked block attribute  }
  43.                CommandLineAttr  : byte;  { Command line attribute  }
  44.                LoStatusLineAttr : byte;  { Status line 1 attribute }
  45.                HiStatusLineAttr : byte;  { Status line 2 attribute }
  46.                MessageAttr      : byte;  { Messages attribute      }
  47.                HelpAttr         : byte;  { Help line attribute     }
  48.                CursorAttr       : byte;  { Virtual cursor attribute}
  49.               END;
  50.  
  51.  MargRecord = RECORD
  52.                 ShiftKeyCount   : word;   { Delay value for secondary help lines }
  53.                 AutoSaveLimit   : word;   { Keystrokes# for autosave             }
  54.                 ScrollAmountGlb : integer;{ Left / Right scroll amount           }
  55.                 DrawModel       : integer;{ Drawing style                        }
  56.                 LeftMargin      : integer;{ Left margin                          }
  57.                 ParMargin       : integer;{ New paragraph margin                 }
  58.                 RightMargin     : integer;{ Right margin                         }
  59.               END;
  60.  
  61.  MessageRecord = RECORD
  62.                   HelpLine          : array[1..4] of string[80];
  63.                     { Help line and 3 secondary help lines }
  64.                   EditErrorMessages : array[1..43] of string[43];
  65.                     { Error messages --> 38 for the english version}
  66.                  END;
  67.  
  68.  StatusRecord =  RECORD
  69.                   linenum,            { Line number of current text    }
  70.                   line    : word;     { Current row in current text    }
  71.                   col,                { Current column in current text }
  72.                   firstcol,           { First displayed column         }
  73.                   lower,              { Displayed lines number         }
  74.                   nbwin   : byte;     { Number of windows              }
  75.                  END;
  76.  
  77. textline   = string;                  { Each line has 255 char. max.       }
  78. lineptr    = ^textline;               { Textflow points to a pointers ar-  }
  79. textflowar = array [0..1] of lineptr; { ray (1 to linenum - see above).    }
  80. textflow   = ^textflowar;             { Each pointer points to a text line.}
  81.  
  82. commandline = string[80];
  83.  
  84. CONST
  85.  
  86.    E_Vec : byte = $C0; { No de l'interruption utilisée par E!  }
  87.  
  88.    { This value may be changed if it conflicts with an already used  }
  89.    { interrupt vector. In this case E!.EXE must be patched to reflect}
  90.    { that change. See E! API USER's GUIDE }
  91.  
  92.    { Values to pass in AH to specify the E! API service you want to use }
  93.    FUNCTION_REQUEST   = 0;   { Call a E! function - code in BX }
  94.  
  95.    EDITBUFF_REQUEST   = 1;   { Request Editbuffer address              }
  96.    FLAGS_REQUEST      = 2;   { Request flags block address             }
  97.    ATTR_REQUEST       = 3;   { Request attribute block address         }
  98.    MARG_REQUEST       = 4;   { Request margins+misc. block address     }
  99.    MESS_REQUEST       = 5;   { Request messages block address          }
  100.    FLOW_REQUEST       = 6;   { Request pointers array address-text flow}
  101.    NAME_REQUEST       = 7;   { Request current name address            }
  102.  
  103.    STATUS_REQUEST     = 8;   { Request curr.line, line#, column etc... }
  104.  
  105.    DISPLINE_SERVICE   = 9;   { Display contents of edit buffer }
  106.    REFRESH_SERVICE    = 10;  { Rebuild the whole E! screeen    }
  107.    MASK_SERVICE       = 11;  { Refresh text mask               }
  108.    STORE_SERVICE      = 12;  { Store edit Buffer to text       }
  109.    CHANGE_SERVICE     = 13;  { Set change flag to true         }
  110.  
  111.    SEEK_SERVICE       = 14;  { Set active line                 }
  112.  
  113.    VERSION_SERVICE    = 15;  { Return version number }
  114.  
  115.    REGISTER_SERVICE   = 16;  { Execute command after exit}
  116.  
  117.    { If AH is set to 0 please use one of the following function code }
  118.    { and pass it to E! API thru BX.                                  }
  119.  
  120.    ALIGN_TEXT         = 001; { Align text to cursor                   }
  121.    PASCAL_STYLE       = 002; { See documentation (Ctrl B)             }
  122.    CLEAR_LINE         = 003; { Clear line                             }
  123.    REPEAT_CHAR        = 004; { Repeat specified character             }
  124.    CLEAR_EOL          = 005; { Erase end of line                      }
  125.    WRAP               = 006; { Toggle Wordwrap                        }
  126.    _43LINES           = 007; { Toggle 35/43/50 lines mode             }
  127.    DELETE_LEFT        = 008; { Delete left character                  }
  128.    NEXT_TAB           = 009; { Go to next tab                         }
  129.    JUSTIFICATION      = 010; { Toggle justify mode                    }
  130.    EDIT               = 012; { Edit a file                            }
  131.    ENTER              = 013; { Insert a line or validate a command    }
  132.    INSERT_NAME        = 014; { Insert filename                        }
  133.    MACRO              = 016; { Execute active macro                   }
  134.    RESTORE_MACRO      = 017; { Restore previous macro                 }
  135.    REPEAT_SEARCH      = 019; { Repeat last search                     }
  136.    INSERT_DATE        = 020; { Insert date and time                   }
  137.    INIT_SEARCH        = 022; { Initialize search variables            }
  138.    DEL_WORD           = 023; { Delet current word                     }
  139.    EXECUTE            = 024; { Execute current line as a command      }
  140.    LIST_DIR           = 026; { List current line as a directory       }
  141.    CHANGE_MODE        = 027; { Toggle between editmode and commandmode}
  142.    REMOVE_LINE        = 127; { Remove current line                    }
  143.    PREV_TAB           = 271; { Go to previous tab                     }
  144.    CONTINUE           = 272; { Insert a continue-mark in macro        }
  145.    END_OF_BLOCK       = 274; { Go to end of block                     }
  146.    REMOVE_TAB         = 275; { Remove current tab position            }
  147.    RECORD_TAB         = 276; { Create a new tab positioneur           }
  148.    BLOCK_BEGIN        = 277; { Go to block begin                      }
  149.    UNMARK             = 278; { Unmark block                           }
  150.    REMOVE_TABS        = 279; { Remove all tab positions               }
  151.    OVERLAY            = 280; { Overlay block at cursor position       }
  152.    PARAGRAPH          = 281; { Go to next paragraph                   }
  153.    ADJUST             = 286; { Adjust block position                  }
  154.    SPLIT              = 287; { Split line at cursor                   }
  155.    DELETE_BLOCK       = 288; { Delete marked block                    }
  156.    FILL_BLOCK         = 289; { Fill block with specified character    }
  157.    SORT               = 290; { Sort block                             }
  158.    BOX                = 291; { Draw a box around the block            }
  159.    JOIN               = 292; { Join current line and next line        }
  160.    BOOKMARK           = 293; { Drop bookmark                          }
  161.    LINE_MARK          = 294; { Mark lines                             }
  162.    SENTENCE_MARK      = 300; { Mark sentences                         }
  163.    GRAPHICS           = 301; { Toggle control characters access       }
  164.    COPY_BLOCK         = 302; { Copy block to cursor position          }
  165.    REMOVE_SPACES      = 303; { Remove trailing blanks                 }
  166.    BLOCK_MARK         = 304; { Mark block                             }
  167.    MOVE_BLOCK         = 306; { Move block                             }
  168.    HELP               = 315; { Load help file                         }
  169.    SAVE               = 316; { Save current file                      }
  170.    QUIT               = 317; { Quit current file                      }
  171.    QUIT_SAVE          = 318; { Quite and save current file            }
  172.    WINDOW             = 319; { Create/Remove window                   }
  173.    DRAW               = 320; { Toggle draw mode                       }
  174.    NAME               = 321; { Name current file                      }
  175.    LOAD               = 322; { Edit a new file                        }
  176.    RESTORE            = 323; { Restore (undo) current line            }
  177.    NEXT               = 324; { Go to next file                        }
  178.    LINE_BEGIN         = 327; { Go to line begin                       }
  179.    UP                 = 328; { Up                                     }
  180.    PREV_PAGE          = 329; { Scroll screen up                       }
  181.    LEFT               = 331; { Left                                   }
  182.    RIGHT              = 333; { Right                                  }
  183.    EOL                = 335; { Go to end of line                      }
  184.    DOWN               = 336; { Down                                   }
  185.    NEXT_PAGE          = 337; { Scroll screen down                     }
  186.    TOGGLE_INSERT      = 338; { Toggle insert mode                     }
  187.    DEL_CHAR           = 339; { Delete character at cursor             }
  188.    SCROLL_RIGHT       = 340; { Scroll right                           }
  189.    SCROLL_LEFT        = 341; { Scroll left                            }
  190.    SCROLL_UP          = 342; { Scroll up                              }
  191.    SCROLL_DOWN        = 343; { Scroll down                            }
  192.    CENTER_LINE        = 344; { Center line in window                  }
  193.    RAISE_LINE         = 345; { Raise line to top of window            }
  194.    UPCASE_WORD        = 350; { Upcase word                            }
  195.    LOWCASE_WORD       = 351; { Lowcase word                           }
  196.    UPCASE_BLOCK       = 352; { Upcase block                           }
  197.    LOWCASE_BLOCK      = 353; { Lowcase block                          }
  198.    CENTER_BLOCK       = 354; { Center text in block                   }
  199.    FORMAT_PAR         = 355; { Format paragraph                       }
  200.    FORMAT_BLOCK       = 356; { Format paragraphs within block         }
  201.    KEYHELP            = 360; { Key oriented help                      }
  202.    PAGE_RIGHT         = 362; { Scroll page right                      }
  203.    PAGE_LEFT          = 363; { Scroll page left                       }
  204.    CHANGE_WINDOW      = 364; { Change active window                   }
  205.    DELETE_WINDOW      = 365; { Supprime une fenêtre                   }
  206.    FULL_SCREEN        = 366; { Supprime les fenêtres                  }
  207.    NEXT_ERROR         = 367; { Go to next compilation error           }
  208.    PREV_ERROR         = 368; { Go to previous compilation error       }
  209.    PREVIOUS           = 369; { Go to previous file                    }
  210.    PREV_WORD          = 371; { Go to previous word                    }
  211.    NEXT_WORD          = 372; { Go to next word                        }
  212.    TEXT_END           = 373; { Go to end of text                      }
  213.    PAGE_BOTTOM        = 374; { Go to bottom of window                 }
  214.    TEXT_BEGIN         = 375; { Go to text begin                       }
  215.    TEXTMARK1          = 376; { Drop text mark 1                       }
  216.    TEXTMARK2          = 377; { Drop text mark 2                       }
  217.    TEXTMARK3          = 378; { Drop text mark 3                       }
  218.    UNMARK_TEXTS       = 379; { Remove text marks                      }
  219.    REFRESH            = 380; { Reload (refresh) original file         }
  220.    PAIRED_BRACE       = 381; { See documentation                      }
  221.    MATCH_BRACE        = 382; { See documentation                      }
  222.    UNDO               = 383; { Restore removed lines                  }
  223.    INSERT_DOS         = 384; { Insert captured lines (DOS SHELL)      }
  224.    SEARCH_WORD        = 385; { Search current word                    }
  225.    INSERT_BLOCK       = 386; { Insert blanks before block             }
  226.    INSERT_BLANK       = 387; { Insert blanks without moving cursor    }
  227.    PAGE_TOP           = 388; { Go to top of window                    }
  228.  
  229. CALLFAILED = $FF;
  230. { A bad function id has been passed to Call_E_Function }
  231.  
  232.  
  233.  
  234. Function  Call_E_Function(funcno : word) : byte;
  235.  { Use this function to execute a E! function }
  236.  
  237. Function  Request_E_Address(request_name : byte) : pointer;
  238.  { Use this function to get the address of E! variables }
  239.  
  240. Procedure Get_E_Status(VAR status : statusrecord);
  241.  { Use this function to get cursor current position and window status }
  242.  
  243. Procedure Request_E_Service(service : byte);
  244.  { Use this function to get special services }
  245.  
  246. Procedure Get_E_Version(VAR major, minor : byte);
  247.  { Retrieve E! version }
  248.  
  249. Procedure RegisterCommand(commandstr : commandline);
  250.  { Execute a E! command after exit}
  251.  
  252. Function Seek_E_Line(line : word; curpos : byte):byte;
  253. { Call E! seek function and return error code }
  254.  
  255. IMPLEMENTATION
  256.  
  257. Function Call_E_Function(funcno : word):byte;
  258. { Call E! function #funcno and return error code }
  259. { Example : retcode:=Call_E_Function(Page_Top)   }
  260.  
  261. VAR  regs : registers;
  262.  
  263. BEGIN
  264.  regs.AH:=0;
  265.  regs.BX:=funcno;
  266.  Intr(E_Vec, regs);
  267.  Call_E_Function:=regs.AL;
  268. END;
  269.  
  270. Function Request_E_Address(request_name : byte):pointer;
  271. { Returns a pointer to the requested variables block }
  272.  
  273. VAR  regs : registers;
  274.  
  275. BEGIN
  276.  IF NOT request_name IN [1..7] THEN Exit;
  277.  regs.AH:=request_name;
  278.  Intr(E_Vec, regs);
  279.  Request_E_Address:=Ptr(regs.ES, regs.BX);
  280. END;
  281.  
  282. Procedure Get_E_Status(VAR status : statusrecord);
  283. { Loads status members with appropriate values }
  284.  
  285. VAR  regs : registers;
  286.  
  287. BEGIN
  288.  regs.AH:=STATUS_REQUEST;
  289.  Intr(E_Vec, regs);
  290.  WITH status DO
  291.  BEGIN
  292.   linenum :=regs.CX;
  293.   line    :=regs.DX;
  294.   col     :=regs.AH;
  295.   firstcol:=regs.AL;
  296.   lower   :=regs.BH;
  297.   nbwin   :=regs.BL;
  298.  END;
  299. END;
  300.  
  301. Procedure Request_E_Service(service:byte);
  302.  
  303. VAR  regs : registers;
  304.  
  305. BEGIN
  306.  regs.AH:=service;
  307.  Intr(E_Vec, regs);
  308. END;
  309.  
  310. Procedure Get_E_Version(VAR major, minor : byte);
  311.  
  312. VAR  regs : registers;
  313.  
  314. BEGIN
  315.  regs.AH:=VERSION_SERVICE;
  316.  Intr(E_Vec, regs);
  317.  major:=regs.AH;
  318.  minor:=regs.AL;
  319. END;
  320.  
  321. Procedure RegisterCommand(commandstr : commandline);
  322.  
  323. VAR  regs : registers;
  324.  
  325. BEGIN
  326.  regs.AH:=REGISTER_SERVICE;
  327.  regs.ES:=Seg(commandstr);
  328.  regs.BX:=Ofs(commandstr);
  329.  Intr(E_Vec, regs);
  330. END;
  331.  
  332. Function Seek_E_Line(line : word; curpos : byte):byte;
  333. { Call E! seek function and return error code }
  334.  
  335. VAR  regs : registers;
  336.  
  337. BEGIN
  338.  regs.AH:=14;
  339.  regs.BX:=line;
  340.  regs.AL:=curpos;
  341.  Intr(E_Vec, regs);
  342.  Seek_E_Line:=regs.AL;
  343. END;
  344.  
  345. END.
  346.